package com.yunlan.materia.controller;

import com.yunlan.materia.entity.Result;
import com.yunlan.materia.request.DeleteDisableBookRequest;
import com.yunlan.materia.request.MateriaMedicaBookRequest;
import com.yunlan.materia.request.NormalAbleBookRequest;
import com.yunlan.materia.request.QueryBookRequest;
import com.yunlan.materia.service.MateriaMedicaBookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 云澜
 * @date 2025/9/17
 * @ApiNote
 */
@Api(value = "书籍模块")
@RestController("/api/materia/medica/book")
public class MateriaMedicaBookController {

    @Autowired
    MateriaMedicaBookService medicaBookService;

    @ApiOperation(value = "添加书籍",notes = "添加书籍",tags = {"书籍模块"})
    @PostMapping("/add")
    public Result addBook(@RequestBody MateriaMedicaBookRequest request){
        return Result.success(medicaBookService.addBook(request));
    }

    @ApiOperation(value = "删除或禁用书籍",notes = "删除或禁用书籍",tags = {"书籍模块"})
    @PostMapping("/delete/disable")
    public Result deleteBook(@RequestBody DeleteDisableBookRequest request){
        return Result.success(medicaBookService.deleteDisableBook(request));
    }

    @ApiOperation(value = "启用书籍",notes = "启用书籍",tags = {"书籍模块"})
    @PostMapping("/able")
    public Result able(@RequestBody NormalAbleBookRequest request){
        return Result.success(medicaBookService.normalAbleBook(request));
    }

    @ApiOperation(value = "根据id查询book",notes = "根据id查询book",tags = {"书籍模块"})
    @GetMapping("/queryBookById")
    public Result queryBookById(@RequestParam("id")Long id){
        return Result.success(medicaBookService.queryBookById(id));
    }

    @ApiOperation(value = "根据name查询book",notes = "根据name查询book",tags = {"书籍模块"})
    @PostMapping("/queryBookByName")
    public Result queryBookByName(@RequestParam("bookName")String bookName){
        return Result.success(medicaBookService.queryBookByName(bookName));
    }

    @ApiOperation(value = "根据request查询book",notes = "根据request查询book",tags = {"书籍模块"})
    @PostMapping("/queryBookList")
    public Result queryBookList(@RequestBody QueryBookRequest request){
        return Result.success(medicaBookService.queryBookList(request));
    }



}
